//
//  TestReversiBoardPosition.m
//  Reversi
//
//  Created by 成瀬 龍人 on 2/6/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TestReversiBoardPosition.h"
#import "ReversiBoardPosition.h"

@implementation TestReversiBoardPosition
- (void)setUp{
}

- (void)tearDown{
}

- (void)testCreatePosition{
	@try{
		ReversiBoardPosition* pos1 = [[ReversiBoardPosition alloc] initWithInt:1:1];
		ReversiBoardPosition* pos2 = [[ReversiBoardPosition alloc] initWithString:@"a":@"a"];	
		STAssertTrue(pos1.x == 1 && pos2.x == 1, @"x = 1");
		STAssertTrue(pos1.y == 1 && pos2.y == 1, @"y = 1");
		pos1 = [[ReversiBoardPosition alloc] initWithInt:1:8];
		pos2 = [[ReversiBoardPosition alloc] initWithString:@"a":@"h"];	
		STAssertTrue(pos1.x == 1 && pos2.x == 1, @"x = 1");
		STAssertTrue(pos1.y == 8 && pos2.y == 8, @"y = 8");
		pos1 = [[ReversiBoardPosition alloc] initWithInt:8:8];
		pos2 = [[ReversiBoardPosition alloc] initWithString:@"h":@"8"];	
		STAssertTrue(pos1.x == 8 && pos2.x == 8, @"x = 8");
		STAssertTrue(pos1.y == 8 && pos2.y == 8, @"y = 8");
		pos1 = [[ReversiBoardPosition alloc] initWithInt:8:1];
		pos2 = [[ReversiBoardPosition alloc] initWithString:@"8":@"a"];	
		STAssertTrue(pos1.x == 8 && pos2.x == 8, @"x = 8");
		STAssertTrue(pos1.y == 1 && pos2.y == 1, @"y = 1");
	}@catch(ReversiOutOfRangeException* e){
		STFail(@"do not throw exception");
	}
}

- (void)testErrorCase{
	STAssertThrows([[ReversiBoardPosition alloc] initWithInt:0:1],@"out of range");
	STAssertThrows([[ReversiBoardPosition alloc] initWithInt:1:9],@"out of range");
	STAssertThrows([[ReversiBoardPosition alloc] initWithString:@"i":@"a"],@"out of range");
	STAssertThrows([[ReversiBoardPosition alloc] initWithString:@"a":@"aaa"],@"out of range");
	
}
@end
